package com.ihighest.app.infox.myview;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ihighest.app.infox.R;

public class SettingSimpleView extends RelativeLayout {
	private TextView simpleItem;
	private ImageView imgRight;

	public SettingSimpleView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		// Constants.changeSize(context, this, true);
	}

	public SettingSimpleView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView(context);
		TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SettingSimpleView);
		String itemName = a.getString(R.styleable.SettingSimpleView_simpleItemName);
		int visible = a.getInt(R.styleable.SettingSimpleView_Visiable, 2);
		if (visible == 2) {
			imgRight.setVisibility(View.VISIBLE);
		} else {
			imgRight.setVisibility(View.GONE);
		}
		setItemName(itemName);
		// Constants.changeSize(context, this, true);
		a.recycle();
	}

	/**
	 * 设置条目
	 * 
	 * @param itemName
	 * 
	 * @author lkx Created at 2015-10-5 上午9:14:08
	 */
	private void setItemName(String itemName) {
		simpleItem.setText(itemName);

	}

	public SettingSimpleView(Context context) {
		super(context);
		initView(context);
	}

	/**
	 * 初始化绑定控件
	 * 
	 * @param context
	 * 
	 * @author lkx Created at 2015-10-5 上午8:58:56
	 */
	private void initView(Context context) {
		View view = View.inflate(context, R.layout.infox_myview_simpleitem, this);
		simpleItem = (TextView) view.findViewById(R.id.mSettingSmpItem);
		imgRight = (ImageView) view.findViewById(R.id.imgRight);
		simpleItem.setTextSize(16.0f);
	}

}
